# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html

import urllib.request
# useful for handling different item types with a single interface
from itemadapter import ItemAdapter


class Wwwjj20ComPipeline:
    def process_item(self, item, spider):
        for i in range(0,len(item['picurl'])):
            thispic = item['picurl'][i]
            trueurl = thispic.split('lp')[0] + '1200.jpg'
            print(trueurl)
            localpath = "D:/www.jj20.com/" + item['title'][i] + '.jpg'
            urllib.request.urlretrieve(trueurl,filename=localpath)
        return item

    #http://img.jj20.com/up/allimg/1112/040Q9141940/1Z40Q41940-1-1200.jpg
    #http://img.jj20.com/up/allimg/1114/0F621112546/210F6112546-1-lp.jpg',

